package com.cz.modules.jxc.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.cz.common.entity.BaseTree;
import com.cz.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.cz.modules.jxc.entity.JxcCashEntity;
import com.cz.modules.jxc.service.JxcCashService;
import com.cz.common.utils.PageUtils;
import com.cz.common.utils.R;



/**
 * 收银机管理
 *
 * @author Cz
 * @email 
 * @date 2020-04-16 13:42:40
 */
@RestController
@RequestMapping("jxc/jxccash")
public class JxcCashController {
    @Autowired
    private JxcCashService jxcCashService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("jxc:jxccash:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = jxcCashService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("jxc:jxccash:info")
    public R info(@PathVariable("id") String id){
        JxcCashEntity jxcCash = jxcCashService.getById(id);

        return R.ok().put("jxcCash", jxcCash);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("jxc:jxccash:save")
    public R save(@RequestBody JxcCashEntity jxcCash){
        jxcCashService.save(jxcCash);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("jxc:jxccash:update")
    public R update(@RequestBody JxcCashEntity jxcCash){
        ValidatorUtils.validateEntity(jxcCash);
        jxcCashService.updateById(jxcCash);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("jxc:jxccash:delete")
    public R delete(@RequestBody String[] ids){
        jxcCashService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }
    /**
     * 商户组织树
     */
    @RequestMapping("/shopTree")
    public R shopTree(){
        return R.ok().put("shopTree",jxcCashService.shopTree());
    }

}
